<?php
class C_m_usergroup extends Nvl_Controller{
	
	function __construct(){
		parent::__construct();
		session_start();
		if(!empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest') {
			if(!isset($_SESSION[SESSION_USERID])){
				$this->output->set_status_header('301');
			}
		}else{
			if(!isset($_SESSION[SESSION_USERID])){
				$this->session->set_flashdata(EXPIRED_SESSION);
				redirect('c_login');
			}
		}
		$this->load->model('m_m_usergroup');
	}
	
	function index(){
		$this->load->view('pages/v_m_usergroup');
	}
	
	function data_list(){
		$params=array(
			"draw"=>$this->input->numeric('draw'),
			"start"=>$this->input->numeric('start'),
			"length"=>$this->input->numeric('length'),
			"filter"=>$this->input->post('filter')
		);
		$result = $this->m_m_usergroup->data_list($params);
		echo $result;
	}
	
	function save(){
		$params = json_decode($this->input->post("params"));
		$result = $this->m_m_usergroup->__save($params->form_data, $params->usergroup_id);
		echo $result;
	}
	
	function delete(){
		$usergroup_id = $this->input->numeric('usergroup_id');
		$result = $this->m_m_usergroup->__delete($usergroup_id);
		echo $result;
	}
}